from distutils.command.config import config

from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QHBoxLayout
from qfluentwidgets import Theme
from qframelesswindow import TitleBar

from app.components.widgets.label import PixmapLabel
from app.components.widgets.stacked_widget import OpacityAniStackedWidget
from app.view.frameless_window.win32 import AcrylicWindow


class MainWindow(AcrylicWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.sub_main_window = None
        self.total_stack_widget = None
        self.isInSelectionMode = False
        # self.versionManager = VersionManager()
        self.navigationHistories = [("myMusicInterfaceStackWidget", 0)]
        self.setObjectName("mainWindow")
        self.create_widgets()
        self.initWidget()
        self.initHotkey()

    def create_widgets(self):
        """
        创建小部件
        :return:
        """
        # 主窗口包含totalStackWidget、播放栏和标题栏
        # totalStackWidget包含subMainWindow、playingInterface和videoWindow
        self.total_stack_widget = OpacityAniStackedWidget(self)

        # subMainWindow用于放置导航界面和subStackWidget
        self.sub_main_window = QWidget(self)

        # create splash screen
        self.splashScreen = SplashScreen(self)

        # create title bar
        self.titleBar = TitleBar(self)




class SplashScreen(QWidget):
    """ Splash screen """

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.hBoxLayout = QHBoxLayout(self)
        self.logo = PixmapLabel(self)
        self.logo.setPixmap(QPixmap(":/images/logo/logo_splash_screen.png"))
        self.hBoxLayout.addWidget(self.logo, 0, Qt.AlignCenter)
        self.setAttribute(Qt.WA_StyledBackground)
        color = '2b2b2b' if config.theme == Theme.DARK else 'ffffff'
        self.setStyleSheet(f'background:#{color}')
